﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GaSaiGon.GUI
{
    public partial class frmXuLyVe : Form
    {
        public frmXuLyVe()
        {
            InitializeComponent();
        }

        private void frmXuLyVe_Load(object sender, EventArgs e)
        {
            ThongTinBUS TTBus = new ThongTinBUS();
            ThongTinDTO TTDto = new ThongTinDTO();
            dgvDanhSach.DataSource = TTBus.DanhSachVeCanXuLy();

            cbxHienTrang.DataSource = TTBus.HienTrang();
            cbxHienTrang.ValueMember = "MaHienTrang";
            cbxHienTrang.DisplayMember = "LoaiHienTrang";
        }

        private void dgvDanhSach_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            lbLyDo.Text = dgvDanhSach.CurrentRow.Cells["LyDo"].Value.ToString();
            cbxHienTrang.SelectedValue = int.Parse(dgvDanhSach.CurrentRow.Cells["HienTrang"].Value.ToString());
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            ThongTinBUS TTBus = new ThongTinBUS();
            ThongTinDTO TTDto = new ThongTinDTO();
            TTDto.MaVe = int.Parse(dgvDanhSach.CurrentRow.Cells["MaVe"].Value.ToString());
            TTDto.HienTrang = int.Parse(cbxHienTrang.SelectedValue.ToString());
            TTBus.CapNhatHienTrangVe(TTDto);
            dgvDanhSach.DataSource = TTBus.DanhSachVeCanXuLy();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
